package com.yystar.user.operator.domain;

import java.io.Serializable;
import java.util.Locale;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;


public class Operator implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -7181485207477426484L;
	public static final String OPERATOR_SESSION_ATTRIBUTE = "OPERATOR_SESSION_ATTRIBUTE";
	public static final String TRADING_EVENT_MARKET_CRITERIA = "TRADING_EVENT_MARKET_CRITERIA";
	public static final String TEL_BET_EVENT_MARKET_CRITERIA = "TEL_BET_EVENT_MARKET_CRITERIA";

	private String opLoginCode;

	private Locale locale;
	
	private int opGroupId = 0;
	
	private int isTrader;
	
	private String opName;
	
	private String opCode;
	
	private int isSubLogin;
	
	private String opGroupName;
	
	private String dateFormat;
	
	private String dateTimeFormat;
	
	private int accessRightNo01 = 0;

	private int accessRightNo02 = 0;

	private int accessRightNo03 = 0;

	private int accessRightNo04 = 0;

	private int accessRightNo05 = 0;

	private int accessRightNo06 = 0;

	private int accessRightNo07 = 0;

	private int accessRightNo08 = 0;

	private int accessRightNo09 = 0;

	private int accessRightNo10 = 0;

	private int accessRightNo11 = 0;

	private int accessRightNo12 = 0;

	private int accessRightNo13 = 0;

	private int accessRightNo14 = 0;

	private int accessRightNo15 = 0;

	private int accessRightNo16 = 0;

	private int accessRightNo17 = 0;

	private int accessRightNo18 = 0;

	private int accessRightNo19 = 0;

	private int accessRightNo20 = 0;
	
	private String token = "";
	
	private java.util.Date loginDateTime = null;
	
	private String clientIpAddr = "";
	
	private String serverIpAddr = "";
	
	private String sessionId = "";
	

	public int getAccessRightNo01() {
		return accessRightNo01;
	}


	public void setAccessRightNo01(int accessRightNo01) {
		this.accessRightNo01 = accessRightNo01;
	}


	public int getAccessRightNo02() {
		return accessRightNo02;
	}


	public void setAccessRightNo02(int accessRightNo02) {
		this.accessRightNo02 = accessRightNo02;
	}


	public int getAccessRightNo03() {
		return accessRightNo03;
	}


	public void setAccessRightNo03(int accessRightNo03) {
		this.accessRightNo03 = accessRightNo03;
	}


	public int getAccessRightNo04() {
		return accessRightNo04;
	}


	public void setAccessRightNo04(int accessRightNo04) {
		this.accessRightNo04 = accessRightNo04;
	}


	public int getAccessRightNo05() {
		return accessRightNo05;
	}


	public void setAccessRightNo05(int accessRightNo05) {
		this.accessRightNo05 = accessRightNo05;
	}


	public int getAccessRightNo06() {
		return accessRightNo06;
	}


	public void setAccessRightNo06(int accessRightNo06) {
		this.accessRightNo06 = accessRightNo06;
	}


	public int getAccessRightNo07() {
		return accessRightNo07;
	}


	public void setAccessRightNo07(int accessRightNo07) {
		this.accessRightNo07 = accessRightNo07;
	}


	public int getAccessRightNo08() {
		return accessRightNo08;
	}


	public void setAccessRightNo08(int accessRightNo08) {
		this.accessRightNo08 = accessRightNo08;
	}


	public int getAccessRightNo09() {
		return accessRightNo09;
	}


	public void setAccessRightNo09(int accessRightNo09) {
		this.accessRightNo09 = accessRightNo09;
	}


	public int getAccessRightNo10() {
		return accessRightNo10;
	}


	public void setAccessRightNo10(int accessRightNo10) {
		this.accessRightNo10 = accessRightNo10;
	}


	public int getAccessRightNo11() {
		return accessRightNo11;
	}


	public void setAccessRightNo11(int accessRightNo11) {
		this.accessRightNo11 = accessRightNo11;
	}


	public int getAccessRightNo12() {
		return accessRightNo12;
	}


	public void setAccessRightNo12(int accessRightNo12) {
		this.accessRightNo12 = accessRightNo12;
	}


	public int getAccessRightNo13() {
		return accessRightNo13;
	}


	public void setAccessRightNo13(int accessRightNo13) {
		this.accessRightNo13 = accessRightNo13;
	}


	public int getAccessRightNo14() {
		return accessRightNo14;
	}


	public void setAccessRightNo14(int accessRightNo14) {
		this.accessRightNo14 = accessRightNo14;
	}


	public int getAccessRightNo15() {
		return accessRightNo15;
	}


	public void setAccessRightNo15(int accessRightNo15) {
		this.accessRightNo15 = accessRightNo15;
	}


	public int getAccessRightNo16() {
		return accessRightNo16;
	}


	public void setAccessRightNo16(int accessRightNo16) {
		this.accessRightNo16 = accessRightNo16;
	}


	public int getAccessRightNo17() {
		return accessRightNo17;
	}


	public void setAccessRightNo17(int accessRightNo17) {
		this.accessRightNo17 = accessRightNo17;
	}


	public int getAccessRightNo18() {
		return accessRightNo18;
	}


	public void setAccessRightNo18(int accessRightNo18) {
		this.accessRightNo18 = accessRightNo18;
	}


	public int getAccessRightNo19() {
		return accessRightNo19;
	}


	public void setAccessRightNo19(int accessRightNo19) {
		this.accessRightNo19 = accessRightNo19;
	}


	public int getAccessRightNo20() {
		return accessRightNo20;
	}


	public void setAccessRightNo20(int accessRightNo20) {
		this.accessRightNo20 = accessRightNo20;
	}

	public String getOpLoginCode() {
		return opLoginCode;
	}

	public void setOpLoginCode(String opLoginCode) {
		this.opLoginCode = opLoginCode;
	}

	public Locale getLocale() {
		return locale;
	}

	public void setLocale(Locale locale) {
		this.locale = locale;
	}
	
	public int getOpGroupId() {
		return opGroupId;
	}

	public void setOpGroupId(int opGroupId) {
		this.opGroupId = opGroupId;
	}

	public int getIsTrader() {
		return isTrader;
	}

	public void setIsTrader(int isTrader) {
		this.isTrader = isTrader;
	}

	public String getOpName() {
		return opName;
	}

	public void setOpName(String opName) {
		this.opName = opName;
	}

	public String getOpCode() {
		return opCode;
	}

	public void setOpCode(String opCode) {
		this.opCode = opCode;
	}

	public int getIsSubLogin() {
		return isSubLogin;
	}

	public void setIsSubLogin(int isSubLogin) {
		this.isSubLogin = isSubLogin;
	}

	public String getOpGroupName() {
		return opGroupName;
	}

	public void setOpGroupName(String opGroupName) {
		this.opGroupName = opGroupName;
	}

	public String getDateFormat() {
		return dateFormat;
	}

	public void setDateFormat(String dateFormat) {
		this.dateFormat = dateFormat;
	}

	public String getDateTimeFormat() {
		return dateTimeFormat;
	}

	public void setDateTimeFormat(String dateTimeFormat) {
		this.dateTimeFormat = dateTimeFormat;
	}

	public java.util.Date getLoginDateTime() {
		return loginDateTime;
	}

	public void setLoginDateTime(java.util.Date loginDateTime) {
		this.loginDateTime = loginDateTime;
	}

	public String getClientIpAddr() {
		return clientIpAddr;
	}

	public void setClientIpAddr(String clientIpAddr) {
		this.clientIpAddr = clientIpAddr;
	}

	public String getServerIpAddr() {
		return serverIpAddr;
	}

	public void setServerIpAddr(String serverIpAddr) {
		this.serverIpAddr = serverIpAddr;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}
	
	public String getSessionId() {
		return sessionId;
	}

	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}


	public boolean canAccess(int accessRightId) {
		boolean result = false;
		
		if (accessRightId < 0) {
			
		} else {
			int groupNo = OperatorGroup.convertAccessRightIdToGroupNo(accessRightId);
			int bitNo = OperatorGroup.convertAccessRightIdToBitNo(accessRightId);
			if (groupNo == 1) {
				result = ((accessRightNo01 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 2) {
				result = ((accessRightNo02 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 3) {
				result = ((accessRightNo03 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 4) {
				result = ((accessRightNo04 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 5) {
				result = ((accessRightNo05 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 6) {
				result = ((accessRightNo06 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 7) {
				result = ((accessRightNo07 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 8) {
				result = ((accessRightNo08 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 9) {
				result = ((accessRightNo09 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 10) {
				result = ((accessRightNo10 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 11) {
				result = ((accessRightNo11 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 12) {
				result = ((accessRightNo12 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 13) {
				result = ((accessRightNo13 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 14) {
				result = ((accessRightNo14 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 15) {
				result = ((accessRightNo15 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 16) {
				result = ((accessRightNo16 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 17) {
				result = ((accessRightNo17 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 18) {
				result = ((accessRightNo18 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 19) {
				result = ((accessRightNo19 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else if (groupNo == 20) {
				result = ((accessRightNo20 / (int)Math.pow(10, bitNo)) % 2) == 1;
			} else {
				result = false;
			}
		}
		
		return result;
	}
	public String getLocaleString() {
		if ("zh_cn".equalsIgnoreCase(locale.getDisplayLanguage())) {
			return "zh_CN";
		} else if ("zh_tw".equalsIgnoreCase(locale.getDisplayLanguage())) {
			return "zh_TW";
		} else 
			return locale.getLanguage();
	}
	
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this,
				ToStringStyle.SHORT_PREFIX_STYLE);
	}

}
